<template>
  <div class="xunaren">
    <statistic-query-form @doQuery="getList" :data-uri="'/kh/statistic/rankInfo/'" :pattern="2" :dept-type="0"></statistic-query-form>
    <p class="titlexuan"><b>干部选拔结果统计表</b> </p>
    <p v-show="biaoyiArrShow" class="xunren">表一、选人用人工作民主评议表</p>
<!--    表一-->
    <div v-show="biaoyiArrShow" v-for="wai in biaoyiArr">
      <el-table
        :data="wai.body"
        class="tablestyle"
        border>
        <el-table-column
          prop="assessItemName"
          align="center"
          label="单位">
        </el-table-column>
        <el-table-column :label="item.title"  align="center" v-for="item in wai.heads">
          <el-table-column
            v-for="row in item.headItems"
            :prop="row.prop"
            align="center"
            :label="row.label">
          </el-table-column>
        </el-table-column>
      </el-table>
    </div>


    <p v-show="biaoyiArrbShow" class="xunren">表二、新选拔任用干部民主评议表</p>
<!--    表一-->
    <div v-show="biaoyiArrbShow" v-for="wai in biaoyiArrb">
      <el-table
        :data="wai.body"
        class="tablestyle"
        border>
        <el-table-column
          prop="assessItemName"
          align="center"
          label="单位">
        </el-table-column>
        <el-table-column :label="item.title"  align="center" v-for="item in wai.heads">
          <el-table-column
            v-for="row in item.headItems"
            :prop="row.prop"
            align="center"
            :label="row.label">
          </el-table-column>
        </el-table-column>
      </el-table>
    </div>

  </div>
</template>

<script>
  import request from '@/utils/request'
  import StatisticQueryForm from '../components/StatisticQueryForm'
  export default {
    name: "Login",
    data() {
      return {
        biaoyiArrShow:true,
        biaoyiArrbShow:true,
        biaoyiArrb:[],
        biaoyiArr:[
          {
            //表头
            hangname:[
              {tltlename:'干部选拔任用工作',
                pjf:'90',
                xxarr:[
                  {xingming:'满意',prop:'name'},
                  {xingming:'不满意',prop:'name1'},
                  {xingming:'不知道',prop:'xiaoji'},
                ]
              },
            ],
            //总数居
            tableData: [
              {
                danwei: '公司1',
                name: '10',
                name1: '20',
                xiaoji:'10',
                heji:10
              },
              {
                danwei: '公司1',
                name: '10',
                name1: '20',
                xiaoji:'10',
                heji:10
              },
            ]
          },
          {
            //表头
            hangname:[
              {tltlename:'干部选拔任用工作1',
                pjf:'90',
                xxarr:[
                  {xingming:'满意',prop:'name'},
                  {xingming:'不满意',prop:'name1'},
                  {xingming:'不知道',prop:'xiaoji'},
                ]
              },
            ],
            //总数居
            tableData: [
              {
                danwei: '公司1',
                name: '10',
                name1: '20',
                xiaoji:'10',
                heji:10
              },
              {
                danwei: '公司1',
                name: '10',
                name1: '20',
                xiaoji:'10',
                heji:10
              },
            ]
          }
        ],
      };
    },
    components:{
      'StatisticQueryForm': StatisticQueryForm
    },
    created() {

    },
    methods: {

      //获取列表数据
      getList:function(obj) {
        this.spanArr=[]
        request({
          url: obj.url,
          method: 'get',
        }).then(response => {
          this.biaoyiArr = response.data.rankstatic2
          this.biaoyiArrb = response.data.rankstatic3
          if(this.biaoyiArr.length>0){
            this.biaoyiArrShow = true
          }else {
            this.biaoyiArrShow = false
          }
          if(this.biaoyiArrb.length>0){
            this.biaoyiArrbShow = true
          }else {
            this.biaoyiArrbShow = false
          }
          for (var i=0;i<this.biaoyiArr.length;i++){
            if(this.biaoyiArr[i].indexSatisfactionType===0){//有平均值
              for (var j=0;j<this.biaoyiArr[i].heads.length;j++){
                this.biaoyiArr[i].heads[j].title =this.biaoyiArr[i].heads[j].title + '  ( 平均分值: '+ this.biaoyiArr[i].heads[j].average.toFixed(2)+' )'
              }
            }

          }
          debugger
          for (var p=0;p<this.biaoyiArrb.length;p++){
            if(this.biaoyiArrb[p].indexSatisfactionType===0){//有平均值
              for (var k=0;k<this.biaoyiArrb[p].heads.length;k++){
                this.biaoyiArrb[p].heads[k].title =this.biaoyiArrb[p].heads[k].title + '  ( 平均分值: '+ this.biaoyiArrb[p].heads[k].average.toFixed(2)+' )'
              }
            }

          }

        });
      },

    }
  };
</script>

<style  lang="scss">
  .xunaren .titlexuan {
    text-align: center;
    font-size: 20px;
  }
  .xunaren .xunren {
    text-align: center;
  }

  .xunaren .tablestyle {
    width: 95%;
    margin-top: 20px;
    font-size: 14px;

  }

</style>
